package com.giaothong.model.entity;

import org.json.JSONObject;

import com.giaothong.utils.JSONUtil;

public class UserEntity {

	public static final String NORNAL_USER = "0";
	public static final String CONG_TAC_VIEN = "1";

	private String userId = "";
	private String userName = "";
	private String name = "";
	private String address = "";
	private String email = "";
	private String phoneNumber = "";
	private String type = "";
	/**
	 * setter & getter
	 */
	public void setAddress(String address) {
		this.address = address;
	}


	public void setEmail(String email) {
		this.email = email;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setPhoneNumber(String phoneNumber) {
		this.phoneNumber = phoneNumber;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getType() {
		return type;
	}

	public String getAddress() {
		return address;
	}

	public String getEmail() {
		return email;
	}

	public String getName() {
		return name;
	}

	public String getPhoneNumber() {
		return phoneNumber;
	}

	public String getUserId() {
		return userId;
	}

	public String getUserName() {
		return userName;
	}

	/**
	 * parse Json
	 */
	public static final String ID = "id";
	public static final String USERNAME = "user_name";
	public static final String NAME = "name";
	public static final String ADDRESS = "address";
	public static final String EMAIL = "email";
	public static final String PHONE_NUMBER = "phone_number";
	public static final String TYPE = "type";

	/**
	 * contructor
	 */
	public UserEntity() {
		setDefautValue();
	}


	public UserEntity(JSONObject jsonObject) {
		setDefautValue();
		if (jsonObject == null)
			return;
		this.address = JSONUtil.stringTryGetValue(jsonObject, ADDRESS);
		this.email = JSONUtil.stringTryGetValue(jsonObject, EMAIL);
		this.name = JSONUtil.stringTryGetValue(jsonObject, NAME);
		this.phoneNumber = JSONUtil.stringTryGetValue(jsonObject, PHONE_NUMBER);
		this.userId = JSONUtil.stringTryGetValue(jsonObject, ID);
		this.userName = JSONUtil.stringTryGetValue(jsonObject, USERNAME);
		this.type = JSONUtil.stringTryGetValue(jsonObject, TYPE);
	}

	private void setDefautValue() {
		this.address = "";
		this.email = "";
		this.name = "";
		this.phoneNumber = "";
		this.userId = "";
		this.userName = "";
		this.type = "";
	}

}
